Removing text from an object containing OLE

Hi,

  Let us say I have an object that has an embedded OLE, this is usually a diagram. In the same object, below or above the OLE is some text . How do I remove just the text and leave the OLE in the object using DXL?

UU


UmaU - Thu Feb 26 14:43:15 EST 2015

Re: Removing text from an object containing OLE
Mathias Mamsch - Fri Feb 27 04:21:02 EST 2015

You have two options:

- use the Richtext / RichTextParagraph perms to parse through the objects richtext and get the OLE object from there

- parse out the OLE object with a suitable regular expression (which is faster in my opinion.

I think for both variants you will find example code on the forum. Regards, Mathias

Re: Removing text from an object containing OLE
GregM_dxler - Fri Feb 27 08:55:40 EST 2015

Mathias Mamsch - Fri Feb 27 04:21:02 EST 2015

You have two options:

- use the Richtext / RichTextParagraph perms to parse through the objects richtext and get the OLE object from there

- parse out the OLE object with a suitable regular expression (which is faster in my opinion.

I think for both variants you will find example code on the forum. Regards, Mathias

You have a third option that might be easier.

Create a buffer

Copy the contents of the object attribute without the OLE to the buffer by the dxl command richTextNoOle.

Then copy the buffer back to the object attribute.

Oh, richTextNoOle only works for copying from one attribute to another.

Nope, it will work.  See code below.

Object o = current
Buffer buf = create
buf = richTextNoOle o."Object Text"
o."Object Text" = richText buf
delete buf

Hope this helps,

Greg

Re: Removing text from an object containing OLE
UmaU - Fri Feb 27 11:11:55 EST 2015

GregM_dxler - Fri Feb 27 08:55:40 EST 2015

You have a third option that might be easier.

Create a buffer

Copy the contents of the object attribute without the OLE to the buffer by the dxl command richTextNoOle.

Then copy the buffer back to the object attribute.

Oh, richTextNoOle only works for copying from one attribute to another.

Nope, it will work.  See code below.

Object o = current
Buffer buf = create
buf = richTextNoOle o."Object Text"
o."Object Text" = richText buf
delete buf

Hope this helps,

Greg

I need the OLE only, not the text.  I want the text gone from the object.

UU

 

Re: Removing text from an object containing OLE
GregM_dxler - Fri Feb 27 11:34:29 EST 2015

UmaU - Fri Feb 27 11:11:55 EST 2015

I need the OLE only, not the text.  I want the text gone from the object.

UU

 

Sorry,

That is what I was starting to look at.  If the attribute is Object Text you can use OleCut and OlePaste to do it.  You basically cut the ole to the system clipboard, clean out the attribute and then paste it back in.  If it is for a different attribute  it is much harder.

Object obj = current 
if (oleIsObject obj){
    if (oleCut obj){
       obj."Object Text" = ""
       if (olePaste obj == false){
          print "Problem trying to paste object\n"
        }
    } else {
        print "Problem trying to cut object\n"
    }
} else {
    print "Does not contain an embedded object in its object text\n"
}

Hope this helps,

Greg

Re: Removing text from an object containing OLE
UmaU - Fri Feb 27 11:36:21 EST 2015

Mathias Mamsch - Fri Feb 27 04:21:02 EST 2015

You have two options:

- use the Richtext / RichTextParagraph perms to parse through the objects richtext and get the OLE object from there

- parse out the OLE object with a suitable regular expression (which is faster in my opinion.

I think for both variants you will find example code on the forum. Regards, Mathias

This worked.

string s = oleCopy(oObj, column 1, 0)

oObj."Object Text" = ""
 
if (olePaste oObj == false)
{
print "Problem trying to paste" 
}

UU

Re: Removing text from an object containing OLE
UmaU - Tue Mar 03 13:44:39 EST 2015

GregM_dxler - Fri Feb 27 11:34:29 EST 2015

Sorry,

That is what I was starting to look at.  If the attribute is Object Text you can use OleCut and OlePaste to do it.  You basically cut the ole to the system clipboard, clean out the attribute and then paste it back in.  If it is for a different attribute  it is much harder.

Object obj = current 
if (oleIsObject obj){
    if (oleCut obj){
       obj."Object Text" = ""
       if (olePaste obj == false){
          print "Problem trying to paste object\n"
        }
    } else {
        print "Problem trying to cut object\n"
    }
} else {
    print "Does not contain an embedded object in its object text\n"
}

Hope this helps,

Greg

Sorry, I hadn't refreshed the page before replying so hadn't seen this response. I had tried using oleCopy/oleCut earlier but seemed to get an exception error and I thought I was doing it wrong. This was while creating a new module thru script, however it worked once I saved the module before using oleCopy.

Thanks for your help.

 

Uma